package net.kts.subskill.tel;

import java.util.ArrayList;

import net.kts.main.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CallAdapter extends BaseAdapter {

	private ArrayList<CallVO> callList;
	private LayoutInflater mInflater;
	public CallAdapter(Context c) {
		mInflater = LayoutInflater.from(c);

	}

	public void setData(ArrayList<CallVO> poolList) {
		callList = poolList;
	}

	@Override
	public int getCount() {
		return callList.size();
	}

	@Override
	public Object getItem(int position) {
		return callList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		
		ViewHolder holder;

		if (convertView == null) {
			convertView	=  mInflater.inflate(R.layout.tel_call_row, null);

			holder = new ViewHolder();

			holder.nameTxt 		= (TextView) convertView.findViewById(R.id.tv_name);
			holder.telTxt 		= (TextView) convertView.findViewById(R.id.tv_tel);
			holder.memoTxt 		= (TextView) convertView.findViewById(R.id.tv_memo);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		CallVO call 	= callList.get(position);
		
		holder.nameTxt.setText(call.getName());
		holder.telTxt.setText(call.getTel());
		holder.memoTxt.setText(call.getMemo());
		
		return convertView;
	}
		
	static class ViewHolder {
		TextView nameTxt;
		TextView telTxt;
		TextView memoTxt;
	}

}
